package javase.static_singleinstance;

class User1 {
    //2.创建一个静态变量来接收对象
    public static User1 SingleInstance1;

    //3.创建一个静态方法，在方法里面创建对象
    public static User1 CreateObject(){
        if (SingleInstance1 == null)
            SingleInstance1 = new User1();
        return SingleInstance1;
    }

    //1.将构造器私有化
    private User1() {
    }

}
